﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<FrontProductViewData>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=ViewData["Page_Title"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <div id="Content">
     <div id="Content-rigth">
	    <div id="product-info">
		   <div>
		      <h1 class="detailTitle"><%=Html.Encode(Model.Product.ProductName) %></h1>
			  <div class="product-brand"><%--品牌名:<a href="#">易昇科技(ESUNINFO)</a>--%>制造商:<%=Html.Encode(Model.Product.Manufacturer) %></div>
			  <div class="product-brand">产地:<%=Html.Encode(Model.Product.Producer)%></div>
			  <div>
			     <div id="product-pic">
				    <script type="text/javascript" language="JavaScript">
						function ShowProduct_openBigPic(pic)
						{
							if(pic != "")
							{
								newWindow = window.open ("/Product/ShowBigImg?pic=" + pic ,"survey_server","resizable,scrollbars,dependent,width=500,height=600,left=150,top=80");
								newWindow.focus();
							}
						}
						function ShowProduct_changePic(pic,midpic)
						{
							document.getElementById("productShowImg").innerHTML = "<a href='#'  onClick=\"ShowProduct_openBigPic('" + pic+ "');\" ><img id=\"ImageShow\" src=\"" + midpic + "\" border=\"0\" class=\"product-pic\"/></a>";
						}
					</script>
					<%if (Model.FrontProductImages.Count() > 0)
       {
           int i = 0;
           foreach (var pic in Model.FrontProductImages)
           {
               if (i == 0)
               { %>
				                <div id="productShowImg">
				                    <a href="#" onclick="ShowProduct_openBigPic('/<%=pic.ImageAddress %>');"><img id="ImageShow" src="/<%=Html.ThumbnailImg(pic.ImageAddress) %>" class="product-pic" border="0"></a>
				                </div>
				                <%i++;
               }
           }%>
				            <div class="viewpic-smim">
				            <%foreach (var pic in Model.FrontProductImages)
                  { %>
					           <div onmouseover="ShowProduct_changePic('/<%=pic.ImageAddress %>','/<%=Html.ThumbnailImg(pic.ImageAddress) %>')" class="viewpic-sm">
					              <a href="#" onclick="ShowProduct_openBigPic('/<%=pic.ImageAddress %>');">
					                  <img src="/<%=Html.ThumbnailImg(pic.ImageAddress) %>"  alt="<%=Html.Encode(Model.Product.ProductName) %>" title="<%=Html.Encode(Model.Product.ProductName) %>" width="27" align="center" border="0" height="27" />
					              </a>
					           </div>
					        <%} %>
					        </div>
					     <%
                        }
       else
       { %>
                    <div id="Div1">
                       <img src="/uploads/def_exp010.gif" alt="<%=Html.Encode(Model.Product.ProductName) %>" title="<%=Html.Encode(Model.Product.ProductName) %>" border="0" />
                    </div>
                   <%} %>
				 </div>
				 <div id="product-detail">
				     <ul>
			              <li class="MarkePrice">市场价：<strike><span class="PriceCharacter">¥</span><%=Html.Encode(String.Format("{0:F}",Model.Product.MarkePrice)) %></strike></li>
			              <li class="SellPrice">
				             优惠价：<span class="PriceCharacter">¥</span><span class="OurPrice"><%=Html.Encode(String.Format("{0:F}",Model.Product.SellPrice)) %></span>
			                 <span class="SalePriceText">为您节省：<span class="SalePrice"><%=Html.GetDifference(Model.Product.MarkePrice,Model.Product.SellPrice)%></span>元&nbsp;(<span class="SaleNumber"><%=Html.GetDiscount(Model.Product.MarkePrice,Model.Product.SellPrice)%></span>折)</span>
			              </li>
						  <li class="Buying"><%=Html.If(Model.Product.Stock > 0, () => "现在有货。", () => "现在缺货。") %> </li>
						  <li><span id="buy" class="buy" ><input type="button" value="放入购物车" onclick="AddShoppingCart()"/></span> <span class="fav"><input type="button" onclick="javascript:top.location='<%=Url.ToFavorites(Model.Product.ProductId) %>';" value="添加到收藏"></span></li>
			          </ul>
					  <div class="statistics">
					     <span>(<a href="<%=Url.ToUserRemark(Model.Product.ProductId) %>">(<%=Html.Encode(Model.RemarkCount) %>) 篇用户评论</a> | <a href="#" onclick="AddRemark()">发表评论</a> | <a href="#" onclick="AddConsultative()">我要咨询</a>)</span>
					  </div>
				 </div>
			  </div>
			  <div class="clear"></div>
		   </div>
		   
		</div>
		<%if (Model.PPCModels.Count() > 0)
    {
        foreach (var prop in Model.PPCModels)
        { %>
	        <div class="content-title"><%=Html.Encode(prop.PropertyName) %></div>
		    <div class="content-description">
               <%=prop.PropertyContent %>
            </div>
        <%}
    }%>
        <div class="content-title">产品描述</div>
		<div class="content-description">
            <%=Model.Product.Description %>
        </div>
        <%=Html.Partial("HelpDiv") %>
		<div id="product-remark">
		    <div class="content-title">用户评论</div>
		    <%if (Model.Remarks.Count() > 0)
        {
            foreach (var rem in Model.Remarks)
            { %>
			<div class="remarkBox">
			    <div class="userpic"></div>
				<div class="userRem">
				    <div class="userNo"><a href="#"><%=Html.Encode(rem.UserName)%></a> 为此商品发表评论  </div>
					<div class="remark-content"><%=Html.Encode(rem.Body)%></div>
					<div class="userRemTime">发表时间：<%=rem.DateTime.ToString("yyyy年MM月dd日") %></div>
				</div>
				<div class="clear"></div>
			</div>
			<%}
        }
        else
        { %>
            <div class="remark-content">还没有用户发表评论！</div>
        <%} %>
			<div class="remark_bottom">
	             与其他用户分享你的观点：<a href="#" onclick="AddRemark()"><em>我要发表评论</em></a><br>
                 <a href="<%=Url.ToUserRemark(Model.Product.ProductId) %>">[浏览全部(<%=Html.Encode(Model.RemarkCount) %>)篇评论]</a>
             </div> 
		</div>
	 </div>
     <div id="Sidebar">
	    <div id="hotSell">
		    <div class="title">同类热销商品</div>
			<div id="leftBox">
			   <%Html.RenderAction("ListHotSell", "Product", new { id = Model.Product.CategoryId });%>
			</div>
			<div class="clear"></div>
		</div>
		
		<div id="leftList">
		    <div class="title">最近浏览的商品</div>
			<div id="leftBox">
			   <ul class="top">
			   <%if (Model.ProductList.Count() > 0)
        {
            foreach (var pl in Model.ProductList)
            {
            %>
			       <li><a href="<%=Url.ToProduct(pl.CategoryId,pl.ProductId) %>"><%=Html.Encode(pl.ProductName) %></a></li>
			   <%}
        } %>   
			   </ul>
			</div>
			<div class="clear"></div>
		</div>
	 </div>
  </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadLink" runat="server">
   <%=Html.Keywords(Html.Encode(ViewData["Page_Keywords"]))%>
   <%=Html.Description(Html.Encode(ViewData["Page_Description"]))%>
   <script language="javascript" type="text/javascript" src="/Resources/JavaScripts/lhgcore.min.js"></script>
   <script language="javascript" type="text/javascript" src="/Resources/JavaScripts/lhgdialog.js"></script>
   <script language="javascript" type="text/javascript">
       $.ajaxSetup({ cache: false });
       function AddShoppingCart() {
           $.get("<%=Url.ToShoppingCart(Model.Product.ProductId,null) %>", function(request) {
               var data = eval("(" + request + ")");
               J.dialog.get('product', { html: '<p align="center" style="font-size:13px">购物车共有 <span style="color:Red">' + data.CartSum + '</span> 种商品   合计 <span style="color:Red">￥' + data.MaxCount + '</span></p><p align="center" style="font-size:14px"><a href="<%=Url.ToShoppingCart()%>" target="_blank">查看购物车</a></p>',
                   width: '300',
                   height: '140',
                   title: '商品成功添加到购物车',
                   cache: false
               });
           });
       }

       function AddRemark() {
           newWindow = window.open("<%=Url.ToAddRemark(Model.Product.ProductId) %>", "survey_server", "resizable,scrollbars,dependent,width=500,height=360,left=200,top=150");
           newWindow.focus();
       }

       function AddConsultative() {
           newWindow = window.open("<%=Url.ToAddConsultative(Model.Product.ProductId) %>", "survey_server", "resizable,scrollbars,dependent,width=500,height=360,left=200,top=150");
           newWindow.focus();
       }
   </script>
</asp:Content>
